import { dialog, ipcMain } from 'electron'

const menu = [
  {
    label: '系统',
    submenu: [
      {
        label: '快速重启',
        accelerator: 'F5',
        role: 'reload'
      },
      {
        label: '退出',
        accelerator: 'CmdOrCtrl+F4',
        role: 'close'
      }
    ]
  },
  {
    label: '游戏',
    submenu: [
      {
        label: '设置',
        accelerator: 'CmdOrCtrl+P',
        click () {
          ipcMain.emit('settings')
        }
      },
      {
        label: '保存',
        accelerator: 'S',
        click () {
          ipcMain.emit('record', false)
        }
      },
      {
        label: '读取',
        accelerator: 'L',
        click () {
          ipcMain.emit('record', true)
        }
      }
    ]
  },
  {
    label: '帮助',
    submenu: [{
      label: '关于',
      click: function () {
        info()
      }
    }]
  }]
function info () {
  dialog.showMessageBox({
    title: '关于',
    type: 'info',
    message: '2048',
    detail: '死胖兽小游戏-2048',
    noLink: true,
    buttons: ['确定']
  })
}

export default menu
